import { Model, ModelCtor, Sequelize } from 'sequelize-typescript'

const fs = require('fs')
const useModels = function (seq: Sequelize) {
  const Models: ModelCtor<Model<any, any>>[] = []
  fs.readdirSync(__dirname).forEach((file: any) => {
    if (file === 'index.js') return
    else if (/.js$/.test(file)) {
      const Model = require(`./${file}`).default
      Models.push(Model)
    }
  })
  seq.addModels(Models)
}
export default useModels
